[求助]java编程华氏度与摄氏度的转换

来源:百度知道 编辑:UC知道 时间:2024/05/15 11:42:08
我是刚刚才学的,压根不会编……我的语言如下:

public class Part1

{

public static void main(String[] args) throws Exception {

BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));

int f = Integer.parseInt(br.readLine());

double c;

c = (5.0 / 9) * (f - 32);
}

}

麻烦高手帮忙修改一下,谢谢了

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestNullPoint {

/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));

double f = Double.parseDouble(br.readLine());

double temp=getTemperature(f);

System.out.println("转换结果为"+temp);
}

/**
* 温度转换
* 华氏度转为温度
* @return
*/
public static double getTemperature(Double d){

Double temp=(d-28)/1.8;
return temp;

}

}
-----------------
公公错了,d-28改成d-32